//
//  LCHomeToolBarView.swift
//  SinaWeiBo
//
//  Created by mac on 16/12/5.
//  Copyright © 2016年 heima. All rights reserved.
//

import UIKit

class LCHomeToolBarView: UIView {
    
    //设置toolBar的数值
    var statusessModel:LCHomeCellViewModel?{
        didSet{
            retweetButton.setTitle(statusessModel?.retweetCountContent, for: .normal)
            commentButton.setTitle(statusessModel?.commentCountContent, for: .normal)
            unlikeButton.setTitle(statusessModel?.unlikeCountContent, for: .normal)
            
        }
        
    }
    
    //懒加载控件
    //转发
    private var retweetButton: UIButton = {
        let button = UIButton(imageName: "timeline_icon_retweet", backgroundImageName: "timeline_card_bottom_background", title: "转发", titleColor: UIColor.gray, fontSize: 14)
        return button
    }()
    //评论
    private var commentButton: UIButton = {
        let button = UIButton(imageName: "timeline_icon_comment", backgroundImageName: "timeline_card_bottom_background", title: "评论", titleColor: UIColor.gray, fontSize: 14)
        return button
    }()
    //点赞
    private var unlikeButton: UIButton = {
        let button = UIButton(imageName: "timeline_icon_unlike", backgroundImageName: "timeline_card_bottom_background", title: "点赞", titleColor: UIColor.gray, fontSize: 14)
        return button
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //布局子控件
    func setupUI(){
        //添加子控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(unlikeButton)
        //设置约束
        
        retweetButton.snp_makeConstraints { (make) in
            make.left.top.bottom.equalTo(self)
            make.width.equalTo(commentButton)
        }
        commentButton.snp_makeConstraints { (make) in
            make.top.bottom.equalTo(self)
            make.leading.equalTo(retweetButton.snp_trailing)
            make.width.equalTo(unlikeButton)
        }
        unlikeButton.snp_makeConstraints { (make) in
            make.top.bottom.trailing.equalTo(self)
            make.leading.equalTo(commentButton.snp_trailing)
        }
        
        let fristLine = addChildLineView()
        let secondLine = addChildLineView()
        
        fristLine.snp_makeConstraints { (make) in
            make.centerX.equalTo(retweetButton.snp_trailing)
            make.centerY.equalTo(self)
        }
        secondLine.snp_makeConstraints { (make) in
            make.centerX.equalTo(commentButton.snp_trailing)
            make.centerY.equalTo(self)
        }
        
    }
    
    //  添加子视图竖线方法
    private func addChildLineView() -> UIImageView {
        let imageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        
        addSubview(imageView)
        
        return imageView
        
    }

    
}
